package com.fzhucc.modules.security.repository;

import com.fzhucc.modules.security.domain.OnlineUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface OnlineUserRepository extends JpaRepository<OnlineUser, Long>, JpaSpecificationExecutor<OnlineUser> {

    void deleteByToken(String token);

    @Modifying
    @Query(nativeQuery = true, value = "DELETE FROM sys_online WHERE expire_time < GETDATE()")
    void deleteAllExpired();

}